﻿package com.gamemeal.geom {
	/**
	 * @author Colin
	 */
	public class Interpolate {
		static private const PI:Number = 3.1415927;
		
		static public function linear(a:Number, b:Number, x:Number):Number{
			return  a*(1-x) + b*x;
		}
		
		static public function cosine(a:Number,b:Number,x:Number):Number{
			var f:Number = (1 - Math.cos(x * PI)) * .5;
			return  a*(1-f) + b*f;
		}
		
		static public function cubic(v0:Number, v1:Number, v2:Number, v3:Number,x:Number):Number{
			var P:Number = (v3 - v2) - (v0 - v1);
			var Q:Number = (v0 - v1) - P;
			var R:Number = v2 - v0;
			var S:Number = v1;

			return Math.pow((P*x),3) + Math.pow((Q*x),2) + R*x + S;
		}
	}
}
